﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace EloamDllDemo
{
    using HELOAMIMAGE = IntPtr;
    using HELOAMIMAGELIST = IntPtr;
    using HELOAMFTP = IntPtr;
    using HELOAMHTTP = IntPtr;
    using HELOAMDEVICE = IntPtr;
    using HELOAMVIDEO = IntPtr;
    using HELOAMVIEW = IntPtr;
    using HELOAMMEMORY = IntPtr;
    using HELOAMBASE64 = IntPtr;
    using HELOAMTHUMBNAIL = IntPtr;
    using HELOAMRECT = IntPtr;
    using HELOAMFONT = IntPtr;
    using HELOAMVIDEOCAP = IntPtr;
    using LPVOID = IntPtr;
    using LONG = Int32;
    using BOOL = Int32;
    using HWND = IntPtr;
    using COLORREF = UInt32;

    public class EloamDll
    {

//         global
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DestroyString",
                CharSet = CharSet.Unicode)]
            public static extern BOOL EloamGlobal_DestroyString(IntPtr str);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_CreateImage")]
            public static extern HELOAMIMAGE EloamGlobal_CreateImage(LONG width, LONG height, LONG channels);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_CreateRect")]
            public static extern HELOAMRECT EloamGlobal_CreateRect(LONG x, LONG y, LONG width, LONG height);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_CreateView")]
            public static extern HELOAMVIEW EloamGlobal_CreateView(HWND hWnd, HELOAMRECT rect, LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_CreateThumbnail")]
            public static extern HELOAMTHUMBNAIL EloamGlobal_CreateThumbnail(HWND hWnd, HELOAMRECT rect, LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_InitDevs")]
            public static extern BOOL EloamGlobal_InitDevs(ELOAM_DEVCHANGECALLBACK fun, LPVOID userData);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DeinitDevs")]
            public static extern BOOL EloamGlobal_DeinitDevs();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_CreateDevice")]
            public static extern HELOAMDEVICE EloamGlobal_CreateDevice(LONG type, LONG idx);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_InitBarcode")]
            public static extern BOOL EloamGlobal_InitBarcode();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DeinitBarcode")]
            public static extern BOOL EloamGlobal_DeinitBarcode();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DiscernBarcode")]
            public static extern BOOL EloamGlobal_DiscernBarcode(HELOAMIMAGE img);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_GetBarcodeCount", CallingConvention = CallingConvention.Cdecl)]
            public static extern LONG EloamGlobal_GetBarcodeCount();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_GetBarcodeData",
                CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
            public static extern string EloamGlobal_GetBarcodeData(LONG idx);

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_VideoCapInit", CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_VideoCapInit();

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_VideoCapStop", CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_VideoCapStop(HELOAMVIDEOCAP cap);

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DestroyVideoCap", CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_DestroyVideoCap(HELOAMVIDEOCAP cap);

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_CreatVideoCap", CallingConvention = CallingConvention.Cdecl)]
            public static extern HELOAMVIDEOCAP EloamGlobal_CreatVideoCap();

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_VideoCapGetAudioDevNum", CallingConvention = CallingConvention.Cdecl)]
            public static extern LONG EloamGlobal_VideoCapGetAudioDevNum();

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_VideoCapPreCap",
                CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_VideoCapPreCap(HELOAMVIDEOCAP m_cap, string  fileName, LONG nSelectMic, LONG FrameRate, LONG compressMode, LONG width, LONG Height, BOOL bCapVideo);
           
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_VideoCapStart",CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_VideoCapStart(HELOAMVIDEOCAP cap);

            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_VideoCapAddVideoSrc", 
                CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_VideoCapAddVideoSrc(HELOAMVIDEOCAP cap, HELOAMVIDEO mVideo);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_InitIdCard",
                    CallingConvention = CallingConvention.Cdecl)]
            //[DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_InitIdCard")]
            public static extern BOOL EloamGlobal_InitIdCard(ELOAM_IDCARDCHANGECALLBACK fun,LPVOID userData);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DeinitIdCard",
                   CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_DeinitIdCard();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_ReadIdCard",
                       CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_ReadIdCard();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DiscernIdCard",
                           CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_DiscernIdCard(ELOAM_IDCARDCHANGECALLBACK fun, LPVOID userData);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_GetIdCardImage")]
            public static extern HELOAMIMAGE EloamGlobal_GetIdCardImage(LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_GetIdCardData",
                        CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
            //[DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_GetIdCardData",
                //CharSet = CharSet.Unicode, CallingConvention = CallingConvention.StdCall)]
            public static extern string EloamGlobal_GetIdCardData(LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_StopIdCardDiscern",
                                       CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_StopIdCardDiscern();


            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_InitFaceDetect",
                                           CallingConvention = CallingConvention.Cdecl)]
            public static extern BOOL EloamGlobal_InitFaceDetect();
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DiscernFaceDetect")]
            public static extern LONG EloamGlobal_DiscernFaceDetect(HELOAMIMAGE img1, HELOAMIMAGE img2);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_GetFaceRect")]
            public static extern HELOAMRECT EloamGlobal_GetFaceRect(HELOAMIMAGE img);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_EnableFaceRectCrop")]
            public static extern HELOAMRECT EloamGlobal_EnableFaceRectCrop(HELOAMVIDEO video, LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DisableFaceRectCrop")]
            public static extern HELOAMRECT EloamGlobal_DisableFaceRectCrop(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamGlobal_DeinitFaceDetect")]
            public static extern HELOAMRECT EloamGlobal_DeinitFaceDetect();
            

//          // image
            [DllImport("eloamDll.dll", EntryPoint = "EloamImage_Release")]
            public static extern LONG EloamImage_Release(HELOAMIMAGE img);
            [DllImport("eloamDll.dll", EntryPoint = "EloamImage_Save",
                CharSet = CharSet.Unicode)]
            public static extern BOOL EloamImage_Save(HELOAMIMAGE img, string  fileName, LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamImage_GetWidth")]
            public static extern LONG EloamImage_GetWidth(HELOAMIMAGE img);
            [DllImport("eloamDll.dll", EntryPoint = "EloamImage_GetHeight")]
            public static extern LONG EloamImage_GetHeight(HELOAMIMAGE img);
            [DllImport("eloamDll.dll", EntryPoint = "EloamImage_Blend")]
            public static extern BOOL EloamImage_Blend(HELOAMIMAGE imgDest, HELOAMRECT rectDest, HELOAMIMAGE imgSrc, HELOAMRECT rectSrc, LONG weight, LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamMemory_Release")]
            public static extern LONG EloamMemory_Release(HELOAMMEMORY mem);

            //EloamImage_DelImageBackColor
            [DllImport("eloamDll.dll", EntryPoint = "EloamImage_DelImageBackColor")]
            public static extern BOOL EloamImage_DelImageBackColor(HELOAMIMAGE image);

//          // device
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_Release")]
            public static extern LONG EloamDevice_Release(HELOAMDEVICE dev);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetFriendlyName")]
            public static extern IntPtr EloamDevice_GetFriendlyName(HELOAMDEVICE dev);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetSubtype")]
            public static extern LONG EloamDevice_GetSubtype(HELOAMDEVICE dev);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetResolutionCount")]
            public static extern LONG EloamDevice_GetResolutionCount(HELOAMDEVICE dev);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetResolutionWidth")]
            public static extern LONG EloamDevice_GetResolutionWidth(HELOAMDEVICE dev, LONG idx);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetResolutionHeight")]
            public static extern LONG EloamDevice_GetResolutionHeight(HELOAMDEVICE dev, LONG idx);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetResolutionCountEx")]
            public static extern LONG EloamDevice_GetResolutionCountEx(HELOAMDEVICE dev, LONG subtype);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetResolutionWidthEx")]
            public static extern LONG EloamDevice_GetResolutionWidthEx(HELOAMDEVICE dev, LONG subtype, LONG idx);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetResolutionHeightEx")]
            public static extern LONG EloamDevice_GetResolutionHeightEx(HELOAMDEVICE dev, LONG subtype, LONG idx);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_ShowProperty")]
            public static extern BOOL EloamDevice_ShowProperty(HELOAMDEVICE dev, HWND hWnd);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_CreateVideo")]
            public static extern HELOAMVIDEO EloamDevice_CreateVideo(HELOAMDEVICE dev, LONG resolution, LONG subtype, ELOAM_ARRIVALCALLBACK funArrival, LPVOID userArrival, ELOAM_TOUCHCALLBACK funTouch, LPVOID userTouch,int resolutionStillCap,int subtypeStillCap);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetEloamType")]
            public static extern LONG EloamDevice_GetEloamType(HELOAMDEVICE dev);
            [DllImport("eloamDll.dll", EntryPoint = "EloamDevice_GetIndex")]
            public static extern LONG EloamDevice_GetIndex(HELOAMDEVICE dev);
//         
//          // video
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_Release")]
            public static extern LONG EloamVideo_Release(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_GetDevice")]
            public static extern HELOAMDEVICE EloamVideo_GetDevice(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_CreateImage")]
            public static extern HELOAMIMAGE EloamVideo_CreateImage(HELOAMVIDEO video, LONG flag, HELOAMVIEW view);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_RotateLeft")]
            public static extern BOOL EloamVideo_RotateLeft(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_RotateRight")]
            public static extern BOOL EloamVideo_RotateRight(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_Flip")]
            public static extern BOOL EloamVideo_Flip(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_Mirror")]
            public static extern BOOL EloamVideo_Mirror(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_EnableDelBkColor")]
            public static extern BOOL EloamVideo_EnableDelBkColor(HELOAMVIDEO video, LONG flag);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_DisableDelBkColor")]
            public static extern BOOL EloamVideo_DisableDelBkColor(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_EnableDeskew")]
            public static extern BOOL EloamVideo_EnableDeskew(HELOAMVIDEO video, LONG flag,int nOffset);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_DisableDeskew")]
            public static extern BOOL EloamVideo_DisableDeskew(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_EnableMoveDetec")]
            public static extern BOOL EloamVideo_EnableMoveDetec(HELOAMVIDEO video, LONG flag, ELOAM_MOVEDETECCALLBACK fun, LPVOID userData);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_DisableMoveDetec")]
            public static extern BOOL EloamVideo_DisableMoveDetec(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_GetWidth")]
            public static extern LONG EloamVideo_GetWidth(HELOAMVIDEO video);
            [DllImport("eloamDll.dll", EntryPoint = "EloamVideo_GetHeight")]
            public static extern LONG EloamVideo_GetHeight(HELOAMVIDEO video);


//         
//          // view
            [DllImport("eloamDll.dll", EntryPoint = "EloamView_Release")]
            public static extern LONG EloamView_Release(HELOAMVIEW view);
            [DllImport("eloamDll.dll", EntryPoint = "EloamView_SelectVideo")]
            public static extern BOOL EloamView_SelectVideo(HELOAMVIEW view, HELOAMVIDEO video, ELOAM_ATTACHCALLBAK fun, LPVOID userData);
            [DllImport("eloamDll.dll", EntryPoint = "EloamView_SetText",
                CharSet = CharSet.Unicode)]
            public static extern BOOL EloamView_SetText(HELOAMVIEW view, string  text, COLORREF clr);
            [DllImport("eloamDll.dll", EntryPoint = "EloamView_PlayCaptureEffect")]
            public static extern BOOL EloamView_PlayCaptureEffect(HELOAMVIEW view);
//         
//          // rect
            [DllImport("eloamDll.dll", EntryPoint = "EloamRect_Release")]
            public static extern LONG EloamRect_Release(HELOAMRECT rect);
//         
//          // thumbnail
            [DllImport("eloamDll.dll", EntryPoint = "EloamThumbnail_Release")]
            public static extern LONG EloamThumbnail_Release(HELOAMTHUMBNAIL thumb);
            [DllImport("eloamDll.dll", EntryPoint = "EloamThumbnail_Add",
                CharSet = CharSet.Unicode)]
            public static extern BOOL EloamThumbnail_Add(HELOAMTHUMBNAIL thumb, string imagePath);


    }
}
